/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PasswordChangePanel.java
 *
 * Created on 2011-03-16, 09:23:23
 */
package guzik.lukasz.UsersExplorer;

import java.util.Arrays;

/**
 *
 * @author byku
 */
public class PasswordChangePanel extends javax.swing.JPanel
{
    String newPwd;

    /** Creates new form PasswordChangePanel */
    public PasswordChangePanel()
    {
	initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jPwdField = new javax.swing.JPasswordField();
        jSecPwdField = new javax.swing.JPasswordField();
        jInfo = new javax.swing.JLabel();

        jLabel1.setText(org.openide.util.NbBundle.getMessage(PasswordChangePanel.class, "PasswordChangePanel.jLabel1.text")); // NOI18N

        jLabel2.setText(org.openide.util.NbBundle.getMessage(PasswordChangePanel.class, "PasswordChangePanel.jLabel2.text")); // NOI18N

        jPwdField.setText(org.openide.util.NbBundle.getMessage(PasswordChangePanel.class, "PasswordChangePanel.jPwdField.text")); // NOI18N
        jPwdField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jPwdFieldKeyReleased(evt);
            }
        });

        jSecPwdField.setText(org.openide.util.NbBundle.getMessage(PasswordChangePanel.class, "PasswordChangePanel.jSecPwdField.text")); // NOI18N
        jSecPwdField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jSecPwdFieldKeyReleased(evt);
            }
        });

        jInfo.setText(org.openide.util.NbBundle.getMessage(PasswordChangePanel.class, "PasswordChangePanel.jInfo.text")); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jInfo, javax.swing.GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel1)
                            .addComponent(jLabel2))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jPwdField, javax.swing.GroupLayout.DEFAULT_SIZE, 111, Short.MAX_VALUE)
                            .addComponent(jSecPwdField, javax.swing.GroupLayout.DEFAULT_SIZE, 111, Short.MAX_VALUE))))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jPwdField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jSecPwdField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jInfo))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jPwdFieldKeyReleased(java.awt.event.KeyEvent evt)//GEN-FIRST:event_jPwdFieldKeyReleased
    {//GEN-HEADEREND:event_jPwdFieldKeyReleased
	newPwd = "0";
	if(Arrays.equals(jPwdField.getPassword(), jSecPwdField.getPassword()))
	{
	    jInfo.setText("Hasła się zgadzają.");
	} else
	{
	    jInfo.setText("Hasła się nie zgadzają");
	}
    }//GEN-LAST:event_jPwdFieldKeyReleased

    private void jSecPwdFieldKeyReleased(java.awt.event.KeyEvent evt)//GEN-FIRST:event_jSecPwdFieldKeyReleased
    {//GEN-HEADEREND:event_jSecPwdFieldKeyReleased
	newPwd = "0";
	if(Arrays.equals(jPwdField.getPassword(), jSecPwdField.getPassword()))
	{
	    jInfo.setText("Hasła się zgadzają.");
	    newPwd = String.valueOf(jPwdField.getPassword());

	} else
	{
	    jInfo.setText("Hasła się nie zgadzają");
	}
    }//GEN-LAST:event_jSecPwdFieldKeyReleased

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jInfo;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPasswordField jPwdField;
    private javax.swing.JPasswordField jSecPwdField;
    // End of variables declaration//GEN-END:variables
}
